<?php
require 'Controller.php ';
require 'admin/model/MusicModel.php';
class MusicController extends Controller{
	function __Construct(){
		parent::__Construct();
		$this->mod = 'musics';
		$this->model = new MusicModel();
	}
function listmusics(){
$data = $this->model->getList();
$this->assign('musics',$data);
$this->display();
	}
	    function musicform(){
        $result = $this->model->getsinger();
        $this->assign("singers",$result);
//        var_dump($result);
        $this->display();
    }


	function add(){
		$data = $_POST;
		$result = $this->model->add($data);
		if($result){
			echo '添加成功 <a href="admin.php?c=music&m=listmusics">如果没有跳转，请点这里跳转</a>';
   			header("refresh:3;url='admin.php?c=music&m=listmusics'");
		}
		else{
			echo "添加失败！<br/>";
  			echo "<a href='admin.php?c=music&m=musicform'>返回</a>";
		}
	}

	    function singerform(){
        $this->display();
    }

	function delmusic(){
		$id = $_GET['id'];
		$model = new MusicModel();
		$result = $model->delmusic($id);
		if($result){
			echo '删除成功 <a href="./admin.php?c=music&m=listmusics">如果没有跳转，请点这里跳转</a>';
   			header("refresh:3;url='./admin.php?c=music&m=listmusics'");
		}
		else{
			echo "删除失败！<br/>";
  			echo "<a href='./admin.php?c=music&m=listmusics'>返回</a>";
		}
	}
	function listsingers(){
$data = $this->model->getsinger();
$this->assign('singers',$data);
$this->display();
	}


			function addsinger(){
		$data = $_POST;
		$result = $this->model->addsinger($data);
		if($result){
			echo '添加成功 <a href="admin.php?c=music&m=listsingers">如果没有跳转，请点这里跳转</a>';
   			header("refresh:3;url='admin.php?c=music&m=listsingers'");
		}
		else{
			echo "添加失败！<br/>";
  			echo "<a href='admin.php?c=music&m=singerform'>返回</a>";
		}
	}
		function delsinger(){
		$id = $_GET['id'];
		$model = new MusicModel();
		$result =$model->delsinger($id);
		if($result){
			echo '删除成功 <a href="./admin.php?c=music&m=listsingers">如果没有跳转，请点这里跳转</a>';
   			header("refresh:3;url='./admin.php?c=music&m=listsingers'");
		}
		else{
			echo "删除失败！<br/>";
  			echo "<a href='./admin.php?c=music&m=listsingers'>返回</a>";
		}
	}
}
?>